//
//  NSString+ReplaceAsterisk.m
//  minidai
//
//  Created by 容贤郁 on 2017/5/7.
//  Copyright © 2017年 迷你金服. All rights reserved.
//

#import "NSString+ReplaceAsterisk.h"

@implementation NSString (ReplaceAsterisk)

- (NSString *)replaceWithAsteriskAtRange:(NSRange)range {
    NSMutableString *start = [NSMutableString string];
    
    if (self.length < range.location || self.length < range.length) {
        return nil;
    }
    
    for (NSInteger i = 0; i < range.length; i++) {
        [start appendString:@"*"];
    }
    
    return [self stringByReplacingCharactersInRange:range withString:start];;
}

@end
